package oop.core.med;

import oop.core.entity.Avatar;
import oop.core.entity.Occupation;
import oop.core.map.Location;
import oop.core.skill.ActiveSkill;
import oop.core.skill.SkillHandler;

/**
 * parameterized with Avatar
 * int skillId
 * occupation
 * equipment
 */
public class SkillMediatorFromHotkey implements SkillMediator, Pausable{
	private SkillHandler skillHandler;
	private Avatar avatar;
	private boolean paused;
	
	public SkillMediatorFromHotkey(SkillHandler skillHandler, Avatar avatar){
		this.skillHandler = skillHandler;
		this.avatar = avatar;
		paused = false;
	}
	public void useSkill(int index){
		if(  paused )
		{
			return;
		}
		ActiveSkill as = avatar.getDerivedActiveSkill(index, avatar.getWeapon());
		Location loc = avatar.getLoc();
		int direction = avatar.getDirection();
		avatar.lowerMP(as.getCost());
		if(as != null)
			skillHandler.register(as, loc, direction);
	}
	
	public void pause() {
		paused = true;
	}
	
	public void toggle() {
		paused = !paused;
	}
	
	public void unpause() {
		paused = false;
	}
}
